﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using FluentValidation;
using CashFlow.Web.Areas.ShopManage.Models.Order;
using CashFlow.Web.Common;

namespace CashFlow.Web.Areas.ShopManage.Validator.Order
{
    public class CreateOrderModelValidator
        : AbstractValidator<CreateOrderModel>
    {
        public CreateOrderModelValidator()
        {
            CascadeMode = CascadeMode.Stop;
            RuleFor(x => x.BuyerUserId).Must(x => CommonValidator.IsUserInShop(x))
                .WithMessage("非法BuyerUserId");
            RuleFor(x => x.SellerUserId).Must(x => CommonValidator.IsUserInShop(x))
                .WithMessage("非法SellerUserId");
            RuleFor(x => x.Amount).Must(x => RegExpTool.IsOrderAmount(x))
                .WithMessage("非法OrderAmount");
        }
    }
}